#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include<stdlib.h>
typedef struct BinaryTreeNode {
    char val;
    struct BinaryTreeNode* left;
    struct BinaryTreeNode* right;
} BTNode;
BTNode* BuyNode(char ch) {
    BTNode* node = (BTNode*)malloc(sizeof(char));
    node->val = ch;
    node->left = node->right = NULL;
    return node;
}
BTNode* BTNCreate(char* a, int* pi) {
    if (a[*pi] == '#') {
        (*pi)++;
        return NULL;
    }

    BTNode* cur = BuyNode(a[(*pi)++]);
    cur->left = BTNCreate(a, pi);
    cur->right = BTNCreate(a, pi);
    return cur;
}
void Inorder(BTNode* root) {
    if (root == NULL)
        return;
    Inorder(root->left);
    printf("%c ", root->val);
    Inorder(root->right);

}
int main() {
    char a[100];
    scanf("%s", a);
    int i = 0;
    BTNode* root = BTNCreate(a, &i);
    Inorder(root);
    return 0;
}